home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PD Collection CD 1
/
PD Collection CD 1.iso
/
programer2
/
blib
/
Docs
/
Memory
< prev
next >
Wrap
Text File
|
1993-03-02
|
2KB
|
43 lines
Technical description of the Dynamic Memory Library version 2
-------------------------------------------------------------
This library supplies the 'Basic' user with dynamic memory allocation. The
library allows convenient memory allocation, and more importantly
deallocation, something lacking from Basic V.
This document contains information about the internal working of the
library. You do not need to know how it works to use it.
When allocating memory the library will first scan it's free memory list for
a block of the relevant size (or greater) using the first-fit algorithm.
If this fails it will claim extra memory from either Basic itself (via
the DIM command) or from the WIMP (by expanding the wimpslot for the
application). Where the library gets new memory from is defined by a
global variable _memdim% (set via library procedures) which if TRUE makes it
claim using the DIM command, and if FALSE memory is claimed from the free
memory pool.
When memory is deallocated (using PROCfree) the block is inserted into the
free space list, joining it up with neighbouring blocks if possible. The free
space list is an ordered list, ordered by address. A check is also made to see
if the wimpslot can safely be reduced because of the deallocation.
Version 2 of the library allocates memory in multiples of 16 bytes (version 1
used multiples of 4). There is also an overhead of 4 bytes per block.
The library performs no integrity checks what-so-ever, and thus any program
which writes over the end of an allocated block may cause the library to
crash or behave incorrectly (although this may not become apparent for some
time). This library has been extensively tested and contains no known bugs
or problems.
Version 2 of the memory library is much faster then version 1 due to the
fact that much of it is not written in assembler (assembled during PROCmemory).
As a consequence it is actually faster then OS_HEAP in general use.
The library also supplies a memory copying routine available for general use.
This routine will copy a given number of bytes (must be a multiple of 4) from
a source address (must be word aligned) to a destination address (aligned).